package com.csxh.web.service.eshop;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csxh.web.dao.IDao;
import com.csxh.web.dao.eshop.SubCategoryDao;
import com.csxh.web.mapper.eshop.SubCategoryMapper;
import com.csxh.web.model.eshop.Subcategory;
import com.csxh.web.model.eshop.SubcategoryCondition;
import com.csxh.web.model.mybatis.Condition;
import com.csxh.web.service.PagerService;

@Service
public class SubCategoryService extends PagerService<Subcategory> {

	private SubCategoryDao thisDao;
	
	@Autowired
	public void setDao(IDao<Subcategory> dao) {

		this.thisDao=((SubCategoryDao) dao);
		
		super.setDao(dao);
	}

	public List<Subcategory> findCategory(int id) {
		Condition condition = new SubcategoryCondition();
		condition.setIdValue(id);

		SqlSession session =this.thisDao.getSessionFactory().openSession();
		SubCategoryMapper mapper = session.getMapper(SubCategoryMapper.class);
		List<Subcategory> list = mapper.selectAllByCondition(condition);
		
		return list;
	}

}
